//
//  LYStatuses.swift
//  微博
//
//  Created by liuerying on 16/5/24.
//  Copyright © 2016年 liuerying. All rights reserved.
//

import UIKit

class LYStatuses: NSObject {

    ///微博ID
    var id: Int64 = 0
    
    ///	微博信息内容
    var text: String?
    
    ///	微博创建时间
    var created_at: String?
    
    ///	微博来源
    var source : String?
    
    //用户信息
    var user: LYUser?
    
    
    //转发的数据
    var retweeted_status:LYStatuses?
    
    var pic_urls:[LYPicture]?
    
    
    //转发数量
    var  reposts_count: Int = 0
    
    //评论
    var  comments_count: Int = 0
    
    //赞
    var attitudes_count: Int = 0
    
    //kvc
    init(dict: [String: AnyObject]) {
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
       //判断是不是user的字典
        if key == "user"{
        
            if let dict = value as? [String: AnyObject]{
            //在赋值
                user = LYUser(dict: dict)
                
            }
        
            return
        }
        
        //判断是不是转发的字典
        if key == "retweeted_status"{
        
            if let dict = value as?[String: AnyObject]{
            
                retweeted_status = LYStatuses(dict: dict)
                
                
            }
            return
        }
        
        if key == "pic_urls"{
        
            if let array = value as? [[String: AnyObject]] {
                
                var tempArray = [LYPicture]()
                
                for item in array{
                
                    let p = LYPicture(dict: item)
                    
                    tempArray.append(p)
                }
                
                pic_urls = tempArray
 
            }
            return
        }
        
        super.setValue(value, forKey: key)
    }
    
    //过滤
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
}



